import Vue from 'vue'
import Router from 'vue-router'
import FurnitureIndex from '@/components/furniture/FurnitureIndex'
import Home from '@/components/Home'
import Index from "@/components/index/Index";
import Cms from "@/components/cms/Cms";

Vue.use(Router)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new Router({
    // 替换hash模式
    mode: 'history',
    routes: [
        {
            path: '/',
            name: 'Home',
            component: Home,
            children: [
                {
                    path: '/cms',
                    name: 'cms',
                    component: Cms
                },
                {
                    path: '/furniture',
                    name: 'furniture',
                    component: FurnitureIndex
                },
                {
                    path: '/index',
                    name: 'Index',
                    component: Index
                }
            ]
        }
    ]
})
